package com.kitten.infrastructure.repository;

import com.kitten.domain.auth.repository.IAuthRepository;
import com.kitten.infrastructure.redis.IRedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Slf4j
@Repository
public class AuthRepository implements IAuthRepository {
    private static final String Key = "openai_kitten_weixin_code";

    @Resource
    private IRedisService redisService;


    @Override
    public String getCodeUserOpenId(String code) {
        return redisService.getValue(Key + "_" + code);
    }

    @Override
    public void removeUserOpenId(String code, String openId) {
        redisService.remove(Key + "_" + openId);
        redisService.remove(Key + "_" + code);
    }
}
